
import selfApi from "@/apis/selfApi";
import userStore from "@/store/userStore";

import { defineStore} from "pinia"

export default defineStore('collection',{
    state:()=>{
        return {
            collectionBokInfo:[]  as any,
            pageNum:1 as number,
            totalPages:1 as number,
            userID:userStore().info.id as any
        }
    },
    actions:{ 
   //获取当前用户收藏的全部博客
   async getCollectionBokByUid(pageNum:any,u_id:any){
    this.collectionBokInfo= (await selfApi.getCollentionBok(pageNum,u_id)).data  as []
    // console.log(this.collectionBokInfo);
    this.pageNum= this.collectionBokInfo?.currentPage;
    this.totalPages= this.collectionBokInfo?.page_count;
    return this.collectionBokInfo
 },
    },
    persist:{
        key:'collectioninfo',
        storage:sessionStorage
   }
 
})